<template>
  <view class="securityCenter">
    <u-cell-group>
      <u-cell-item title="修改密码" @click="$utils.jumpToOtherPage({'jumpUrl':'/pages/mine/set/securityCenter/updatePwdTab'})"></u-cell-item>
      <u-cell-item title="注销账户" @click="handLogoff"></u-cell-item>
    </u-cell-group>
  </view>
</template>

<script>
import clStorage from "@/utils/storage"
export default {
  data() {
    return {
    };
  },

  methods: {
    handLogoff(){
      let _this = this
      uni.showModal({
        title: "警告",
        content: "您确定要注销当前账号吗？账户注销后将无法再次登录，并会清除当前账号所有数据！",
        confirmText: "确定注销",
        confirmColor: "#FF0000",
        cancelText: "取消",
        success: (res) => {
          if (res.confirm) {
            uni.showModal({
              title: "谨慎操作",
              content: "再次向您确认，您确定要注销当前账号吗？",
              confirmText: "坚持注销",
              confirmColor: "#FF0000",
              cancelText: "取消",
              success: (res) => {
                if (res.confirm) {
                  _this.$clApi.login.logoff().then(res => {

                    uni.showToast({
                      title: "您的注销申请已经提交，系统将自动注销当前账号",
                      duration: 10000,
                    });
                    setTimeout(() => {
                     _this.$utils.jumpToHome()
                    }, 1000);
                  })

                }
              },
            });
          }
        },
      });
    },
    /**
     * 退出登录接口
     */
    logout(){
      this.$clApi.login.logout().then(res =>{
        clStorage.setAccessToken("");
        clStorage.setRefreshToken("");
        clStorage.setUserInfo({});
        clStorage.setHasLogin(false)
      })
    },
  },
};
</script>

<style lang="scss" scoped>
.securityCenter {
  .u-cell {
    line-height: normal;
  }
}
</style>
